From: Jonas Dreßler Date: Tue, 8 Jul 2025 14:54:47 +0000 (+0200) Subject: Replace ClutterClickAction with new ClutterClickGesture X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~104^2^2~46 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=0bf49afda33de8a8f0bddd1509254b412195366c;p=gnome-shell.git Replace ClutterClickAction with new ClutterClickGesture Nothing fancy either here, replace the old ClutterClickActions with the new ClutterClickGesture. Part-of: --- diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index 6aea0fdf7..3fa758dca 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -2495,16 +2495,14 @@ export const AppFolderDialog = GObject.registerClass({ this.add_constraint(new Layout.MonitorConstraint({primary: true})); - const clickAction = new Clutter.ClickAction(); - clickAction.connect('clicked', () => { - const [x, y] = clickAction.get_coords(); - const actor = - global.stage.get_actor_at_pos(Clutter.PickMode.ALL, x, y); - - if (!this._viewBox.contains(actor)) - this.popdown(); - }); - this.add_action(clickAction); + const clickGesture = new Clutter.ClickGesture(); + clickGesture.connect('may-recognize', () => { + const coords = clickGesture.get_coords_abs(); + const [, x, y] = this.child.transform_stage_point(coords.x, coords.y); + return !this._viewBox.allocation.contains(x, y); + }); + clickGesture.connect('recognize', () => this.popdown()); + this.add_action(clickGesture); this._source = source; this._folder = folder; diff --git a/js/ui/backgroundMenu.js b/js/ui/backgroundMenu.js index c88d1efc1..26fd41eef 100644 --- a/js/ui/backgroundMenu.js +++ b/js/ui/backgroundMenu.js @@ -44,21 +44,20 @@ export function addBackgroundMenu(actor, layoutManager) { if (actor._backgroundMenu.isOpen) return; - const coords = longPressGesture.get_coords(); - const point = new Graphene.Point3D({x: coords.x, y: coords.y}); - const transformedPoint = actor.apply_transform_to_point(point); - openMenu(transformedPoint.x, transformedPoint.y); + const {x, y} = longPressGesture.get_coords_abs(); + openMenu(x, y); }); actor.add_action(longPressGesture); - const clickAction = new Clutter.ClickAction(); - clickAction.connect('clicked', action => { - if (action.get_button() === 3) { - let [x, y] = action.get_coords(); - openMenu(x, y); - } + const clickGesture = new Clutter.ClickGesture({ + required_button: Clutter.BUTTON_SECONDARY, + recognize_on_press: true, }); - actor.add_action(clickAction); + clickGesture.connect('recognize', () => { + const {x, y} = clickGesture.get_coords_abs(); + openMenu(x, y); + }); + actor.add_action(clickGesture); actor.connect('destroy', () => { actor._backgroundMenu.destroy(); diff --git a/js/ui/messageList.js b/js/ui/messageList.js index 1d2453b0a..265d7a3f9 100644 --- a/js/ui/messageList.js +++ b/js/ui/messageList.js @@ -856,7 +856,7 @@ export const NotificationMessageGroup = GObject.registerClass({ }, }, class NotificationMessageGroup extends St.Widget { constructor(source) { - const action = new Clutter.ClickAction(); + const action = new Clutter.ClickGesture(); // A widget that covers stacked messages so that they don't receive events const cover = new St.Widget({ @@ -912,7 +912,7 @@ export const NotificationMessageGroup = GObject.registerClass({ }); this._unexpandButton.connect('clicked', () => this.emit('expand-toggle-requested')); - action.connect('clicked', () => this.emit('expand-toggle-requested')); + action.connect('recognize', () => this.emit('expand-toggle-requested')); this._headerBox.add_child(this._unexpandButton); this.add_child(this._headerBox); diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index a068ced5e..ced8a5ae8 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -103,18 +103,18 @@ export const PopupBaseMenuItem = GObject.registerClass({ this._activatable = params.reactive && params.activate; this._sensitive = true; - this._clickAction = new Clutter.ClickAction({ + this._clickGesture = new Clutter.ClickGesture({ enabled: this._activatable, }); - this._clickAction.connect('clicked', + this._clickGesture.connect('recognize', () => this.activate(Clutter.get_current_event())); - this._clickAction.connect('notify::pressed', () => { - if (this._clickAction.pressed) + this._clickGesture.connect('notify::pressed', () => { + if (this._clickGesture.pressed) this.add_style_pseudo_class('active'); else this.remove_style_pseudo_class('active'); }); - this.add_action(this._clickAction); + this.add_action(this._clickGesture); if (!this._activatable) this.add_style_class_name('popup-inactive-menu-item'); diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js index 6de759906..4513ff287 100644 --- a/js/ui/screenshot.js +++ b/js/ui/screenshot.js @@ -3036,13 +3036,15 @@ class PickPixel extends St.Widget { }); this.add_constraint(constraint); - const action = new Clutter.ClickAction(); - action.connect('clicked', async () => { - await this._pickColor(...action.get_coords()); + const clickGesture = new Clutter.ClickGesture(); + clickGesture.connect('recognize', async () => { + const {x, y} = clickGesture.get_coords_abs(); + + await this._pickColor(x, y); this._result = this._color; this._grabHelper.ungrab(); }); - this.add_action(action); + this.add_action(clickGesture); this._recolorEffect = new RecolorEffect({ chroma: new Cogl.Color({ diff --git a/js/ui/workspace.js b/js/ui/workspace.js index 25c39aa5d..05817b3a7 100644 --- a/js/ui/workspace.js +++ b/js/ui/workspace.js @@ -1068,20 +1068,20 @@ class Workspace extends St.Widget { if (monitorIndex !== Main.layoutManager.primaryIndex) this.add_style_class_name('external-monitor'); - const clickAction = new Clutter.ClickAction(); - clickAction.connect('clicked', action => { + const clickGesture = new Clutter.ClickGesture({ + required_button: Clutter.BUTTON_PRIMARY, + }); + clickGesture.connect('recognize', () => { // Switch to the workspace when not the active one, leave the // overview otherwise. - if (action.get_button() === 1 || action.get_button() === 0) { - const leaveOverview = this._shouldLeaveOverview(); + const leaveOverview = this._shouldLeaveOverview(); - this.metaWorkspace?.activate(global.get_current_time()); - if (leaveOverview) - Main.overview.hide(); - } + this.metaWorkspace?.activate(global.get_current_time()); + if (leaveOverview) + Main.overview.hide(); }); - this.bind_property('mapped', clickAction, 'enabled', GObject.BindingFlags.SYNC_CREATE); - this._container.add_action(clickAction); + this.bind_property('mapped', clickGesture, 'enabled', GObject.BindingFlags.SYNC_CREATE); + this._container.add_action(clickGesture); this.connect('style-changed', this._onStyleChanged.bind(this)); this.connect('destroy', this._onDestroy.bind(this)); diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js index a34ebd44f..34feaa1af 100644 --- a/js/ui/workspaceThumbnail.js +++ b/js/ui/workspaceThumbnail.js @@ -93,10 +93,10 @@ export const WindowClone = GObject.registerClass({ this); this.inDrag = false; - const clickAction = new Clutter.ClickAction(); - clickAction.connect('clicked', + const clickGesture = new Clutter.ClickGesture(); + clickGesture.connect('recognize', () => this.emit('selected', Clutter.get_current_event_time())); - this._draggable.addClickAction(clickAction); + this.add_action(clickGesture); let iter = win => { let actor = win.get_compositor_private(); @@ -631,13 +631,14 @@ export const ThumbnailsBox = GObject.registerClass({ this._thumbnails = []; - const clickAction = new Clutter.ClickAction(); - clickAction.connect('clicked', () => { + const clickGesture = new Clutter.ClickGesture(); + clickGesture.connect('recognize', () => { + const coords = clickGesture.get_coords(); this._activateThumbnailAtPoint( - ...clickAction.get_coords(), + coords.x, coords.y, Clutter.get_current_event_time()); }); - this.add_action(clickAction); + this.add_action(clickGesture); Main.overview.connectObject( 'showing', () => this._createThumbnails(), @@ -719,9 +720,7 @@ export const ThumbnailsBox = GObject.registerClass({ this.queue_relayout(); } - _activateThumbnailAtPoint(stageX, stageY, time) { - const [r_, x] = this.transform_stage_point(stageX, stageY); - + _activateThumbnailAtPoint(x, y, time) { const thumbnail = this._thumbnails.find(t => x >= t.x && x <= t.x + t.width); if (thumbnail) thumbnail.activate(time); diff --git a/src/st/st-entry.c b/src/st/st-entry.c index fad92ae67..e3a4b537f 100644 --- a/src/st/st-entry.c +++ b/src/st/st-entry.c @@ -1338,11 +1338,11 @@ st_entry_get_input_hints (StEntry *entry) } static void -_st_entry_icon_clicked_cb (ClutterClickAction *action, - ClutterActor *actor, - StEntry *entry) +icon_click_gesture_recognize_cb (ClutterClickGesture *gesture, + StEntry *entry) { StEntryPrivate *priv = ST_ENTRY_PRIV (entry); + ClutterActor *actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (gesture)); if (!clutter_actor_get_reactive (CLUTTER_ACTOR (entry))) return; @@ -1367,17 +1367,17 @@ _st_entry_set_icon (StEntry *entry, if (new_icon) { - ClutterAction *action; + ClutterAction *click_gesture; *icon = g_object_ref (new_icon); clutter_actor_set_reactive (*icon, TRUE); clutter_actor_add_child (CLUTTER_ACTOR (entry), *icon); - action = clutter_click_action_new (); - clutter_actor_add_action_with_name (*icon, "entry-icon-action", action); - g_signal_connect (action, "clicked", - G_CALLBACK (_st_entry_icon_clicked_cb), entry); + click_gesture = clutter_click_gesture_new (); + clutter_actor_add_action_with_name (*icon, "entry-icon-click-gesture", click_gesture); + g_signal_connect (click_gesture, "recognize", + G_CALLBACK (icon_click_gesture_recognize_cb), entry); } clutter_actor_queue_relayout (CLUTTER_ACTOR (entry));